#pragma once
#include "ElementNode.h"
#include "math.h"
#include "grid3x3.h"
#include "Button.h"
namespace NBGUI
{
	class GUIAPI ScrollBar: public ElementNode, public Grid3x3
	{
	public:

		ScrollBar(GUIDrawer* drawer, const char* name, const char* eleText, int eleType = NONE, Rect& _rect = Rect(), float _occupy = 1.0f);
		~ScrollBar();

		void buildVI(std::vector<Vertex>* vertices, std::vector<unsigned int>* indices,unsigned int screenWidth, unsigned int screenHeight);
		void buildArrowVI( std::vector<Vertex>* vertices, std::vector<unsigned int>* indices,unsigned int screenWidth, unsigned int screenHeight );

		void draw();
		void refreshPos(float deltaPos);
		void handleEvent(Event* e);

		void doSomething(std::vector<info>& i, std::string& funcName);
		//void doSomething(std::vector<info>& i);
	protected:
		vec2f uv[8];//back and front
		vec2f uv_arrow[8];
		float occupy;
		float currentPos;
		unsigned int backVertexOffset;
		unsigned int frontVertexOffset;
		Button* upArrow;
		Button* downArrow;
		bool isDraging;
	};
}